class Solution {
    vector<string> numToStr = { "", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
    vector<string> ans;
    string tmp;

    void backTracking(const string& digits, int pos)
    {
        if (pos == digits.size())
        {
            ans.push_back(tmp);
            return;
        }
        int num = digits[pos] - '0';
        string str = numToStr[num];
        for (int i = 0; i < str.size(); ++i)
        {
            tmp += str[i];
            backTracking(digits, pos + 1);
            tmp.pop_back();
        }
    }
public:
    vector<string> letterCombinations(string digits) {
        if (digits.empty()) return ans;
        backTracking(digits, 0);
        return ans;
    }
};